import { reactive, onMounted } from 'vue'
import axios, { type AxiosResponse } from 'axios'

interface DogInter {
    message: string,
    status: string
}

export default function () {
    const dogList = reactive<string[]>([])
    async function getDog() {
        try {
            const result: AxiosResponse<DogInter> = await axios.get('http://127.0.0.1:8000/random_image')
            const img_info = result.data.message
            console.log(result)
            dogList.push(img_info)
        } catch (e) {
            console.log(e);
        }
    }
    onMounted(() => {
        getDog()
    })
    return { dogList, getDog }
}